import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;


public class RemoveURLDateQuotes {

	private static String RemoveUrl(String s)
    {
		boolean thereExist = true; 
		String string = s;
		while(thereExist){
			if(string.indexOf("http") == -1)
				thereExist = false;
			else{
				int i = string.indexOf("http");
				String url = "";
				while(i!=string.length() && string.charAt(i)!= '\\' && string.charAt(i)!=' '){
					url = url + string.charAt(i);
					i++;
				}
				string = string.replace(url, "");
				url = "";
			}
		}
		return string;
		
    }
	
	public static String RemoveQuote(String s){
		
		s = s.replaceAll("\\\"", " ");
		s = s.replace("\\;", " ");
		s = s.replace("\\ ", " ");
		s = s.replaceAll("[^\\x00-\\x7F]", "");
		
		
		return s;
	}
	
	public static String RemoveDate(String s) {
		String[] split = s.split(" ");
		if(split[split.length-1].equals("2013")){
			if(split[split.length-6].equals("Mon") || split[split.length-6].equals("Tue") || split[split.length-6].equals("Wed") ||
					split[split.length-6].equals("Thu") || split[split.length-6].equals("Fri") || split[split.length-6].equals("Sat") ||
					split[split.length-6].equals("Sun")){
				String x = "";
				for(int i = 0 ; i < split.length-6; i++){
					x = x + split[i];
				}
				return x;
			}
			else{
				String x = "";
				for(int i = 0 ; i < split.length-5; i++){
					x = x + split[i];
				}
				return x;
			}
				
		}
		else 
			return s;
	}
	
	public static boolean isDouble(String s){
		try{
			Double.parseDouble(s);
		}catch(NumberFormatException e){
			return false;
		}
		return true;
	}
	
	public static void main(String[] args){
		File inFile = new File("F:/splitTrain/splitPerShow/GGVTweetsOnly.txt");
		File outFile = new File("F:/splitTrain/splitPerShow/GGVCleanFinal.txt");
		 try {
			 BufferedReader reader = new BufferedReader(new FileReader(inFile));
			 BufferedWriter writer = new BufferedWriter(new FileWriter(outFile));
			 String line = reader.readLine();
	         while (line != null) {
	        	String newLine = RemoveUrl(line); 
	        	newLine = RemoveQuote(newLine);
	        	newLine = RemoveDate(newLine);
	        	if(!newLine.equals("") && !isDouble(newLine))
	        		writer.write(newLine + "\n"); 
	        	 line = reader.readLine();
	         }
			 
			 
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
